package com.mk.admin.service.impl;

import com.mk.admin.mapper.*;
import com.mk.admin.model.*;
import com.mk.admin.model.entity.*;
import com.mk.admin.model.vo.*;
import com.mk.admin.service.*;
import com.mk.admin.util.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.stereotype.*;

import java.util.*;
import java.util.stream.*;

@Service
public class EleOrderServiceImpl implements EleOrderService {
    @Autowired
    private EleOrderMapper eleOrderMapper;

    @Override
    public ResultDto select(EleOrderVo eleOrderVo) {
        EleOrderEntity entity = JSONCopy.copy(eleOrderVo, EleOrderEntity.class);
        return ResultDto.data(eleOrderMapper.select(entity));
    }

    public ResultDto add(EleOrderVo eleOrderVo) {
        EleOrderEntity entity = JSONCopy.copy(eleOrderVo, EleOrderEntity.class);
        entity.setStartTime(DateTool.format());
        return ResultDto.data(eleOrderMapper.insert(entity));
    }


    public ResultDto update(EleOrderVo eleOrderVo) {
        EleOrderEntity entity = JSONCopy.copy(eleOrderVo, EleOrderEntity.class);
        return ResultDto.data(eleOrderMapper.updateById(entity));
    }

    @Override
    public ResultDto delete(int id) {
        return ResultDto.data(eleOrderMapper.deleteById(id));
    }

    @Override
    public ResultDto addBatch(EleOrderBatchVo vo) {
        List<EleOrderVo> list = vo.getList();
        List<EleOrderEntity> entityList = JSONCopy.copy(list, EleOrderEntity.class);
        System.out.println("entityList");
        System.out.println(entityList);
        return ResultDto.data(eleOrderMapper.addBatch(entityList));
    }
}
